/**
 * 
 */
package com.meetingshow.privilege.service;

import java.util.ArrayList;
import java.util.List;

import com.meetingshow.common.base.dao.model.QueryStruct;
import com.meetingshow.common.base.service.BaseServiceImp;
import com.meetingshow.common.base.service.model.QueryResults;
import com.meetingshow.privilege.dao.UserDAO;
import com.meetingshow.privilege.dao.model.UserPO;
import com.meetingshow.privilege.service.model.UserQueryParas;
import com.meetingshow.privilege.service.util.UserQueryParasBuilder;
import com.meetingshow.privilege.service.util.UserServiceParas;

/**
 * @author louyi
 *
 */
public class UserServiceImp extends BaseServiceImp implements IUserService {
    private UserDAO userDAO;
    
    /**
     * @return the userDAO
     */
    public UserDAO getUserDAO() {
        return userDAO;
    }

    /**
     * @param userDAO the userDAO to set
     */
    public void setUserDAO(UserDAO userDAO) {
        this.userDAO = userDAO;
    }

    /* (non-Javadoc)
     * @see com.meetingshow.privilege.service.IUserService#saveUser(com.meetingshow.privilege.dao.model.UserPO)
     */
    @Override
    public Integer saveUser(UserPO userPO) throws Exception {
        return getUserDAO().saveUser(userPO);
    }

    /* (non-Javadoc)
     * @see com.meetingshow.privilege.service.IUserService#updateUser(com.meetingshow.privilege.dao.model.UserPO)
     */
    @Override
    public void updateUser(UserPO userPO) throws Exception {
        getUserDAO().updateUser(userPO);
    }

    /* (non-Javadoc)
     * @see com.meetingshow.privilege.service.IUserService#removeUser(com.meetingshow.privilege.dao.model.UserPO)
     */
    @Override
    public void removeUser(UserPO userPO) throws Exception {
        getUserDAO().removeUser(userPO);
    }
    
    @Override
    public UserPO loadUserById(Integer userId) throws Exception {
        return getUserDAO().loadUserById(userId);
    }

    /* (non-Javadoc)
     * @see com.meetingshow.privilege.service.IUserService#queryUser(com.meetingshow.privilege.service.model.UserQueryParas)
     */
    @Override
    public QueryResults<UserPO> queryUser(UserQueryParas userQueryParas)
            throws Exception {
        QueryStruct queryStruct = new QueryStruct();
        List<String> tableList = new ArrayList<String>();
        List<String> returnObjectList = new ArrayList<String>();
        
        tableList.add(UserServiceParas.USERPO);
        returnObjectList.add(UserServiceParas.USERPO);
        
        queryStruct.setTableList(tableList);
        queryStruct.setReturnObjectList(returnObjectList);
        
        queryStruct = UserQueryParasBuilder.userQueryBuilder(queryStruct, userQueryParas);
        QueryResults<UserPO> queryResults = getUserDAO().queryUser(queryStruct);
        return queryResults;
    }

}
